import service from '@/api/service'
import type { MenuVo, RouteMenu } from '@/type/Menu'
import type { Page } from '@/type/User'
import type { PageQuery } from '@/type/common/list-types'

const mapping = 'menu'

/* 获取当前用户的权限菜单 */
export const routeMenuApi = () => service.get<RouteMenu[]>(`${mapping}/route`)

/* 根据菜单编号获取菜单信息 */
export const menuInfoApi = (menuId: string) => service.get<MenuVo>(`${mapping}/${menuId}`)

/* 条件分页查询菜单 */
export const menuListApi = (pageQuery: PageQuery) =>
  service.post<Page<RouteMenu[]>>(`${mapping}/page`, pageQuery)

/* 保存菜单 */
export const saveMenuApi = (menuVo: MenuVo) =>
  service.put(`${mapping}`, menuVo)